/*
 * WaterBag.h
 *
 *  Created on: 02/09/2013
 *      Author: steiner
 */

#ifndef WATERBAG_H_
#define WATERBAG_H_

double WaterBag(int, long, long, double, double, double*, double*, double*, double*);

#endif /* WATERBAG_H_ */

#include <stdio.h>
#include <stdlib.h>
#include "ran2.h"

void WaterBag(int op, long n, long seed, double vel_0, double pos_0, double *pos, double *p, double *mass, double *vel){

	int i;
	long idum;
	idum = -seed;


	for(i = 0 ; i < n ; i++){
		vel[i] = vel_0 * ((double) ran2(&idum) - 0.5);
		pos[i] = pos_0 * ((double) ran2(&idum) - 0.5);
	}

	if(op == 0){
		for(i = 0 ; i < n ; i++){
			mass[i] = 1 + (double) ran2(&idum);
		}
	}

	if(op == 1){
		for(i = 0 ; i < n ; i++){
			if(i % 2 == 0 ){
				mass[i] = 2;
			}else{
				mass[i] = 3;
			}
		}
	}

	for (i = 0; i < n; ++i) {
		p[i] = mass[i]*vel[i];
	}


	return;
}
